import { setToken, getToken, delToken } from '@/utils/storage'

export default {
  namespaced: true,
  state () {
    return {
      // 一进页面默认从本地读取数据
      token: getToken()
    }
  },
  mutations: {
    setUserToken (state, payload) {
      state.token = payload
      // 存入本地
      setToken(payload)
    },
    // 退出清除token
    logout (state) {
      state.token = ''
      // 本地的也同步删除
      delToken()
    }
  }
}
